﻿using DatabaseAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Liguo.AppCode;

namespace Liguo.Store
{
    public partial class GetBackPasswordSuccess : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] != null)
            {
                String UserName = (String)Session["UserName"];
                SqlIt sql = new SqlIt();
                String Password = Request.Form["password"];
                String Salt = Utilities.GetSalt();
                String MD5Pwd = Utilities.GetMD5(Password + Salt);
                Dictionary<string, string> info = new Dictionary<string, string>();
                info["Password"] = MD5Pwd;
                info["Salt"] = Salt;
                String NewXCode = Utilities.RandomString(64);
                info["XCode"] = NewXCode;
                info["XTime"] = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss");
                new SqlIt().UpdateMess("UserInfo", info, "UserName='" + UserName + "'");
                Response.Write("密码修改成功！");
            }
            else
            {
                Response.Write("<script>alert(\"信息错误！\");</script>");
                Response.Write("<script>top.location=\"Port.aspx\";</script>");
            }
        }
    }
}